package com.triones.api.controller.web;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.triones.api.entity.ApplyVipRecordDO;
import com.triones.api.entity.KickbackExtractDO;
import com.triones.api.entity.KycVerifyDO;
import com.triones.api.entity.MemberDO;
import com.triones.api.entity.param.*;
import com.triones.api.entity.vo.*;
import com.triones.api.service.MemberService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用户列表
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/system/member")
public class MemberController extends BaseController {

    private final MemberService memberService;

    /**
     * 用户列表（分页）
     */
    @SaCheckPermission("system:memberUser:list")
    @GetMapping("/pageList")
    public TableDataInfo<CustomMemberVO> pageList(MemberParams memberParams, PageQuery pageQuery) {
        return memberService.pageList(memberParams, pageQuery);
    }

    /**
     * 用户详情
     */
    @SaCheckPermission("system:memberUser:query")
    @GetMapping("/detail/{id}")
    public R<CustomMemberVO> getDetail(@PathVariable("id") Long id) {
        return R.ok(memberService.getDetail(id));
    }

    /**
     * 会员用户列表（分页）
     */
    @SaCheckPermission("system:memberVip:list")
    @GetMapping("/vip/pageList")
    public TableDataInfo<CustomMemberVO> vipPageList(MemberParams memberParams, PageQuery pageQuery) {
        memberParams.setIsVip("1");
        return memberService.pageList(memberParams, pageQuery);
    }

    /**
     * 系统添加白标用户
     */
    @SaCheckPermission("system:memberUser:setVip")
    @PutMapping("/sysSetVip")
    public R<Void> sysSetVip(@Validated @RequestBody MemberDO dto) {
        return toAjax(memberService.sysSetVip(dto));
    }

    /**
     * 系统审核白标申请
     */
    @SaCheckPermission("system:memberUser:auditVipApply")
    @PutMapping("/vipApply/audit")
    public R<Void> auditVipApply(@Validated @RequestBody ApplyVipRecordDO dto) {
        return toAjax(memberService.auditVipApply(dto));
    }

    /**
     * 白标申请列表（分页）
     */
    @SaCheckPermission("system:vipApply:list")
    @GetMapping("/vipApply/pageList")
    public TableDataInfo<CustomApplyVipRecordVO> vipApplyPageList(ApplyVipRecordParams applyVipRecordParams, PageQuery pageQuery) {
        return memberService.vipApplyPageList(applyVipRecordParams, pageQuery);
    }

    /**
     * 邀请用户列表（分页）
     */
    @GetMapping("/invite/pageList")
    public TableDataInfo<CustomInviteRecordVO> inviteMemberPageList(InviteMemberParams inviteMemberParams, PageQuery pageQuery) {
        return memberService.inviteMemberPageList(inviteMemberParams, pageQuery);
    }

    /**
     * 用户列表
     */
    @GetMapping("/list")
    public R<List<MemberVO>> list() {
        return R.ok(memberService.list());
    }

    /**
     * 佣金收益列表（分页）
     */
    @SaCheckPermission("system:kickback:list")
    @GetMapping("/kickback/pageList")
    public TableDataInfo<KickbackRecordVO> kickbackPageList(KickbackParams kickbackParams, PageQuery pageQuery) {
        return memberService.kickbackPageList(kickbackParams, pageQuery);
    }

    /**
     * 佣金提现审核列表（分页）
     */
    @SaCheckPermission("system:kickbackExtractApply:list")
    @GetMapping("/kickbackExtract/apply/pageList")
    public TableDataInfo<KickbackExtractVO> kickbackExtractApplyPageList(KickbackExtractParams kickbackParams, PageQuery pageQuery) {
        return memberService.kickbackExtractApplyPageList(kickbackParams, pageQuery);
    }

    /**
     * 佣金提现记录列表（分页）
     */
    @SaCheckPermission("system:kickbackExtract:list")
    @GetMapping("/kickbackExtract/pageList")
    public TableDataInfo<KickbackExtractVO> kickbackExtractPageList(KickbackExtractParams kickbackParams, PageQuery pageQuery) {
        return memberService.kickbackExtractPageList(kickbackParams, pageQuery);
    }

    /**
     * 佣金提现审核
     */
    @SaCheckPermission("system:kickbackExtract:audit")
    @PutMapping("/kickbackExtract/audit")
    public R<Void> kickbackExtractAudit(@RequestBody KickbackExtractDO dto) {
        return toAjax(memberService.kickbackExtractAudit(dto));
    }
}
